//
//  PANavView.m
//  PAMobileWallet
//
//  Created by shen pu on 13-7-9.
//  Copyright (c) 2013年 平安付. All rights reserved.
//

#import "PANavView.h"

@implementation PANavView
@synthesize delegate;
@synthesize gobackButton;
@synthesize gobackImage;
@synthesize titleLable;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        UIImageView * navImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"public_navbg.png"]];
        navImage.frame = CGRectMake(0, 0, self.frame.size.width, 44);
        navImage.backgroundColor = [UIColor clearColor];
        [self addSubview:navImage];

        gobackImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"public_navbackBT.png"]];
        gobackImage.frame = CGRectMake(20, (44-24)/2 , 33/2, 48/2);
        gobackImage.backgroundColor = [UIColor clearColor];
        [self addSubview:gobackImage];
        
        //返回按钮
        gobackButton = [UIButton buttonWithType:UIButtonTypeCustom];
        gobackButton.frame = CGRectMake(0, 0 , 100, 44);
        gobackButton.backgroundColor = [UIColor clearColor];
        [gobackButton addTarget:self action:@selector(gotoback:) forControlEvents:UIControlEventTouchUpInside];
        //[gobackButton setTransform: CGAffineTransformMakeRotation(0.5*M_PI)];
        gobackButton.tag = 0;
        [self addSubview:gobackButton];
        
        titleLable = [[UILabel alloc] initWithFrame:CGRectMake((frame.size.width - 200)/2, 0, 200, 44)];
        titleLable.backgroundColor = [UIColor clearColor];
        titleLable.textAlignment = NSTextAlignmentCenter;
        titleLable.textColor = [UIColor whiteColor];
        [titleLable setFont:[UIFont boldSystemFontOfSize:20.0]];
        [self addSubview:titleLable];
    }
    return self;
}

- (void)gotoback:(UIButton *)sender
{
    if (delegate)
    {
        [delegate sendSelf:self];
    }
}

- (void)setTitle:(NSString *)getString
{
    if ([getString length] > 0)
    {
        titleLable.text = getString;
    }
}

@end
